<?php
namespace app\admin\loglic;

class Tag
{
    public function fields($data=[])
    {
        $module   = DcEmpty($data['term_module'],'index');
        $controll = 'tag';
        $action   = DcEmpty($data['term_action'],'index');
        $fields = [
            'term_id' => [
                'order'           => 2,
                'type'            => 'hidden',
                'value'           => $data['term_id'],
                'data-filter'     => false,
                'data-visible'    => true,
                'data-width'      => '80',
                'data-width-unit' => 'px',
                'data-sortable'   => true,
                'data-sort-name'  => 'term_id',
                'data-order'      => 'asc',
            ],
            'term_status' => [
                'order'           => 0,
                'type'            => 'select',
                'value'           => DcEmpty($data['term_status'],'normal'),
                'option'          => model('common/Attr','loglic')->statusOption(),
                'class'           => 'form-group col-md-2',
                'data-filter'     => true,
                'data-visible'    => false,
            ],
            'term_status_text' => [
                'order'           => 92,
                'data-title'      => lang('term_status'),
                'data-visible'    => true,
                'data-width'      => '100',
            ],
            'term_type' => [
                'order'           => 93,
                'type'            => 'select',
                'option'          => model('common/Attr','loglic')->tagType(),
                'value'           => $data['term_type'],
                'class'           => 'form-group col-md-2',
                'data-filter'     => true,
                'data-visible'    => true,
                'data-width'      => 100,
            ],
            'term_parent' => [
                'order'           => 91,
                'type'            => 'text',
                'value'           => intval($data['term_parent']),
                'class'           => 'form-group col-md-2',
                'data-filter'     => false,
                'data-visible'    => true,
                'data-width'      => 100,
            ],
            'term_action' => [
                'order'           => 97,
                'type'            => 'text',
                'value'           => $action,
                'class'           => 'form-group col-md-2',
                'data-filter'     => true,
                'data-visible'    => true,
                'data-width'      => 100,
                'data-value'      => $action,
            ],
            'term_controll' => [
                'order'           => 98,
                'type'            => 'text',
                'value'           => $controll,
                'disabled'        => true,
                'class'           => 'form-group col-md-2',
                'data-filter'     => false,
                'data-visible'    => true,
                'data-width'      => 100,
            ],
            'term_module' => [
                'order'           => 99,
                'type'            => 'text',
                'value'           => $module,
                'class'           => 'form-group col-md-2',
                'data-filter'     => true,
                'data-visible'    => true,
                'data-width'      => 100,
                'data-value'      => $module,
            ],
            'term_name' => [
                'order'           => 4,
                'type'            => 'text',
                'value'           => $data['term_name'],
                'class'           => 'form-group col-md-4',
                'required'        => true,
                'data-filter'     => false,
                'data-visible'    => true,
                'data-align'      => 'left',
            ],
            'term_slug' => [
                'order'           => 5,
                'type'            => 'text',
                'value'           => $data['term_slug'],
                'class'           => 'form-group col-md-4',
                'data-filter'     => false,
                'data-visible'    => true,
                'data-align'      => 'left',
            ],
            'term_info' => [
                'order'           => 9,
                'type'            => 'text',
                'value'           => $data['term_info'],
                'class'           => 'form-group col-md-4',
                'data-filter'     => false,
                'data-visible'    => false,
            ],
            'term_limit' => [
                'order'           => 0,
                'type'            => 'number',
                'value'           => $data['term_limit'],
                'class'           => 'form-group col-md-4',
            ],
            'term_tpl' => [
                'order'           => 0,
                'type'            => 'text',
                'value'           => $data['term_tpl'],
                'class'           => 'form-group col-md-4',
            ],
            'term_order' => [
                'order'           => 95,
                'type'            => 'text',
                'value'           => intval($data['term_order']),
                'class'           => 'form-group col-md-4',
                'data-filter'     => false,
                'data-visible'    => true,
                'data-sortable'   => true,
                'data-width'      => '100',
            ],
            'term_title' => [
                'order'           => 6,
                'type'            => 'text',
                'value'           => $data['term_title'],
                'class'           => 'form-group col-md-4',
            ],
            'term_keywords' => [
                'order'           => 7,
                'type'            => 'text',
                'value'           => $data['term_keywords'],
                'class'           => 'form-group col-md-4',
            ],
            'term_description' => [
                'order'           => 8,
                'type'            => 'text',
                'value'           => $data['term_description'],
                'class'           => 'form-group col-md-4',
            ],
            'term_count' => [
                'order'           => 96,
                'data-filter'     => false,
                'data-visible'    => true,
                'data-sortable'   => true,
                'data-width'      => '100',
            ],
        ];
        //动态扩展字段
        if($customs = model('common/Term','loglic')->metaList($module, $controll, $action)){
            $fields = array_merge($fields, DcFields($customs, $data));
        }
        //返回所有表单字段
        return adminFormRow($fields,'col-md-6');
    }
}